package com.hopu.blb_erp.service.impl;


import com.hopu.blb_erp.entity.Commodity;
import com.hopu.blb_erp.entity.PageEntity;
import com.hopu.blb_erp.mapper.CommodityMapper;
import com.hopu.blb_erp.service.CommodityService;
import com.hopu.blb_erp.service.ICommodityService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author A-Zhang
 * @since 2021-11-17
 */
@Service
public class CommodityServiceImpl extends ServiceImpl<CommodityMapper, Commodity> implements CommodityService {

  @Autowired
  private CommodityMapper commodityMapper;
  @Override
  public List<Commodity> selectTIo(String name) {
    return commodityMapper.selectTIo(name);
  }
  @Override
  public Commodity selectTIos(String name) {
    return commodityMapper.selectTIos(name);
  }

  @Override
  public PageEntity<Commodity> listPage(Integer current,Integer pageSize,String pName,String pEnterprise) {
    Integer count = commodityMapper.selectCount(pName,pEnterprise);
    List<Commodity> commodities = commodityMapper.selectPage((current - 1) * pageSize, pageSize,pName,pEnterprise);
    PageEntity<Commodity> pageEntity = new PageEntity<>();
    pageEntity.setCurrent(current);
    pageEntity.setData(commodities);
    pageEntity.setCount(count);
    return pageEntity;
  }
}
